﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UI.View.Repairs
{
    /// <summary>
    /// AnPaiWeixiu.xaml 的交互逻辑
    /// </summary>
    public partial class AnPaiWeixiu : UserControl
    {
        ViewModel.RepairViewModel vm;
        public AnPaiWeixiu()
        {
                        
            InitializeComponent();
            vm = DataContext as ViewModel.RepairViewModel;
        }

        private void Btn_Save_Click(object sender, RoutedEventArgs e)
        {
            if(vm.CurrRepair==null)
            {
                HandyControl.Controls.Growl.WarningGlobal("请选择维修单！");
                return;
            }


            if(vm.CurrRepair !=null)
            {
                vm.CurrRepair.Repairman = txt_WeixiuRen.Text;
                vm.CurrRepair.RepairmanTel = txt_Tel.Text;
                vm.CurrRepair.State = "维修中";
                Model.DataContext context = new Model.DataContext();
                context.DB.Updateable<Model.R_Repair>(vm.CurrRepair).ExecuteCommand();
                HandyControl.Controls.Growl.SuccessGlobal("安排维修完成！");
                vm.GetDaiBan();
                vm.Dialog.Close();
            }
          
        }

        private void Btn_Cancle_Click(object sender, RoutedEventArgs e)
        {
            vm.Dialog.Close();
        }
    }
}
